package com.arlin.springcloud.service;

import com.arlin.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName: DeptClientServiceFallbackFactory
 * @Description: TODO
 * @Author: arlin
 * @Date: 2021/3/22
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {

    @Override
    public Object create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public Dept get(Long id) {
                return new Dept()
                        .setDeptNo(id)
                        .setName("id==>"+ id + "服务降级，没有对应的信息，null---hystrix")
                        .setDbSource("no this database in MySQL");
            }

            @Override
            public List<Dept> getAll() {
                return null;
            }
        };
    }
}
